<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link href="/css/layui.css" rel="stylesheet">
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form  class="form-horizontal m-t" id="signupForm">
                        <input type="hidden" th:value="${merchant.userId}" name = "userId">
                        <div class="form-group" th:if="${!merchFlag}">
                            <label class="col-sm-2 control-label">一级代理商：</label>
                            <div class="col-sm-4">
                                <span class="form-control" th:text="${oneAgent}"></span>
                            </div>
                            <label class="col-sm-2 control-label">二级级代理商：</label>
                            <div class="col-sm-4">
                                <span class="form-control" th:text="${subAgent}"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商户名称：</label>
                            <div class="col-sm-4">
                                <input id="merchantsName" name="merchantsName" readonly class="form-control" th:value="${merchant.merchantsName}" type="text" required>
                            </div>
                            <label class="col-sm-2 control-label">通道分类：</label>
                            <div class="col-sm-4">
                                <select id="payChannelType" name="payChannelType" class="form-control" disabled>
                                    <option th:each="pct:${payChannelTypes}" th:value="${pct.key}" th:text="${pct.value}" th:selected="${merchant.payChannelType==pct.key}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">联系人：</label>
                            <div class="col-sm-4">
                                <input id="contacts" name="contacts" readonly class="form-control" maxlength="20" th:value="${merchant.contacts}" type="text">
                            </div>
                            <label class="col-sm-2 control-label">联系人电话：</label>
                            <div class="col-sm-4">
                                <input id="contactsPhone" name="contactsPhone" readonly class="form-control" maxlength="12" th:value="${merchant.contactsPhone}" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">联系人邮箱：</label>
                            <div class="col-sm-4">
                                <input id="contactsEmail" name="contactsEmail" readonly class="form-control" maxlength="50" th:value="${merchant.contactsEmail}" type="text">
                            </div>
                            <label class="col-sm-2 control-label">联系人QQ：</label>
                            <div class="col-sm-4">
                                <input id="contactsQq" name="contactsQq" readonly class="form-control" maxlength="15" th:value="${merchant.contactsQq}" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2  control-label">
                                商户logo：
                            </label>
                            <label class="col-sm-4 control-label" style="text-align: left">
                                <img id="logo_url_img"  height="50" th:src="${merchant.logoUrl}"/>
                            </label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">提现CNY最小值：</label>
                            <div class="col-sm-4">
                                <input id="acpCnyMin" name="acpCnyMin" readonly class="form-control" th:value="${merchant.acpCnyMin}" min="0" max="999999"  onkeyup="NumberCheck(this)" type="number" required>
                            </div>
                            <label class="col-sm-2 control-label">提现CNY最大值：</label>
                            <div class="col-sm-4">
                                <input id="acpCnyMax" name="acpCnyMax" readonly class="form-control" th:value="${merchant.acpCnyMax}" min="0" max="9999999999"  onkeyup="NumberCheck(this)" type="number" required>
                            </div>
                        </div>
                        <div class="form-group" th:each="payCoin:${payCoins}">
                            <label class="col-sm-2 control-label" th:text="${payCoin.value + ' 手续费率：'}"></label>
                            <div class="col-sm-2">
                                <input th:id ="coinRate_+${payCoin.key}" readonly class="form-control" min="0" maxlength="4" type="number" required>
                            </div>
                            <div class="col-sm-3">
                                <label th:each="unit:${rateUnits}" class="radio-inline">
                                    <input th:name="coinRateUnit_+${payCoin.key}" disabled type="radio" th:value="${unit.key}"
                                           th:text="${unit.value}">
                                </label>
                            </div>
                            <div class="col-sm-3 hidden">
                                <label th:each="oo:${onOff}" class="radio-inline">
                                    <input th:name="coinSwitch_+${payCoin.key}" disabled type="radio" th:value="${oo.key}"
                                           th:text="${oo.value}">
                                </label>
                            </div>
                        </div>
                        <div class=form-group">
                            <label class="col-sm-2 control-label">商户公钥：</label>
                            <div class="col-sm-10">
                                <textarea rows="3" style="width: 100%;resize: none" th:text = "${merchant.publicKey}" readonly></textarea>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/layui.js"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    payCoins = [[${payCoins}]];
    coinRate = [[${merchant.coinRate}]];
    coinSwitch = [[${merchant.coinSwitch}]];
    /*]]>*/
</script>
<script type="text/javascript">
    $().ready(function() {
        for(payCoin in payCoins){
            var unitVal = 1;
            if(coinRate && coinRate[payCoin]){
                $("#coinRate_" + payCoin).val(coinRate[payCoin].rate);
                unitVal = coinRate[payCoin].unit || 1;
                $("input[name=coinRateUnit_" + payCoin + "]").each(function(){
                    if($(this).val() == unitVal){
                        $(this).prop("checked","checked");
                    }
                })
            }
            if(coinSwitch){
                unitVal = coinSwitch[payCoin] || 0;
                $("input[name=coinSwitch_" + payCoin + "]").each(function(){
                    if($(this).val() == unitVal){
                        $(this).prop("checked","checked");
                    }
                })
            }
        }
    });
    function NumberCheck(t){
        var num = t.value;
        var re=/^\d*$/;
        if(!re.test(num)){
            isNaN(parseInt(num))?t.value=0:t.value=parseInt(num);
        }
    }
</script>
</body>
</html>
